<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../js/layui/css/layui.css" media="all">

    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<table class="layui-hide" id="test" lay-filter="test"></table>
<script src="../js/layui/layui.js" charset="utf-8"></script>
<script src="/js/layui/jquery.1.12.4.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>修改</legend>
</fieldset>
<form class="layui-form" id="add-form" action="" method="post">
    <div class="layui-form-item center">
        <label class="layui-form-label" style="width: 100px"></label>
        <div class="layui-input-block">
            <input type="text" name="ID" style="display:none" required value=${vio.id} style="width: 240px"
            lay-verify="required"
            placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item center">
        <label class="layui-form-label" style="width: 100px">处理人:</label>
        <div class="layui-input-block">
            <input type="text" name="handler" required value=${vio.handler} style="width: 240px" lay-verify="required"
            placeholder="请输入处理人姓名" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item center">
        <label class="layui-form-label" style="width: 100px">学生姓名：</label>
        <div class="layui-input-block">
            <input type="text" name="name" required value=${vio.student} style="width: 240px" lay-verify="required"
            placeholder="请输入名字" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item center">
        <label class="layui-form-label" style="width: 100px">扣分：</label>
        <div class="layui-input-block">
            <input type="number" name="deduct_marks" required value=${vio.score} style="width: 240px"
            lay-verify="required"
            placeholder="请输入分数" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">处分原因：</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="reason" class="layui-textarea">${vio.reason}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input class="layui-btn" lay-submit onclick="updateinfo()" lay-filter="save" value="立即修改">
        </div>
    </div>
</form>


<script>
    function updateinfo() {
        $.ajax({
            type: "POST",
            url: "/admin/violateInfo/edit",
            data: $('#add-form').serialize(),
            success: function (msg) {
                if (msg.code == 200) {
                    alert("修改成功！");
                    layer.msg('修改成功！');
                }
                if (msg.code == 201) {
                    alert("分数不足！");layer.msg('分数不足！');
                }
                if (msg.code == 202) {
                    alert("扣0分是没有意义的"); layer.msg('扣0分是没有意义的！');
                }
                if (msg.code == 203) {
                    alert("该学生的积分已为0！"); layer.msg('该学生的积分已为0！');
                }
                if (msg.code == 204) {
                    alert("学生姓名不存在！"); layer.msg('学生姓名不存在！');
                }
            },

        });
    }
</script>

</body>
</html>
</div>
</body>
</html>